package main

import "fmt"

type MyStack struct {
	list []int
}

/** Initialize your data structure here. */
func Constructor() MyStack {
	return MyStack{[]int{}}
}

/** Push element x onto stack. */
func (this *MyStack) Push(x int) {
	this.list = append(this.list, x)
}

/** Removes the element on top of the stack and returns that element. */
func (this *MyStack) Pop() int {
	if len(this.list) != 0 {
		tmp := this.list[len(this.list)-1]
		this.list = this.list[:len(this.list)-1]
		return tmp
	} else {
		return 0
	}

}

/** Get the top element. */
func (this *MyStack) Top() int {
	return this.list[len(this.list)-1]

}

/** Returns whether the stack is empty. */
func (this *MyStack) Empty() bool {

	return len(this.list) == 0
}

/**
 * Your MyStack object will be instantiated and called as such:
 * obj := Constructor();
 * obj.Push(x);
 * param_2 := obj.Pop();
 * param_3 := obj.Top();
 * param_4 := obj.Empty();
 */

func main() {
	obj := Constructor()
	obj.Push(3)
	obj.Push(4)
	obj.Push(5)
	fmt.Println(obj.Top())
	obj.Pop()
	fmt.Println(obj.Top())
	fmt.Println(obj.Empty())
	obj.Pop()
	obj.Pop()
	fmt.Println(obj.Empty())
	obj.Pop()

}
